package com.example.administrator.ffmpeg;

import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Surface;
import android.view.View;
import android.widget.Spinner;

import com.example.administrator.ffmpeg.view.VideoView;

import java.io.File;

public class MainActivity extends AppCompatActivity {


    private JasonPlayer player;
    private VideoView videoView;
    private Spinner sp_video;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        videoView = (VideoView) findViewById(R.id.video_view);
//        sp_video = (Spinner) findViewById(R.id.sp_video);
        player = new JasonPlayer();
        //多种格式的视频列表
     /*   String[] videoArray = getResources().getStringArray(R.array.video_list);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1,
                android.R.id.text1, videoArray);
        sp_video.setAdapter(adapter);*/
    }

    public void mPlay(View btn) {
//        String video = sp_video.getSelectedItem().toString();
        File inputFile = new File(Environment.getExternalStorageDirectory(), "input.mp4");
        if (inputFile.isFile())
            Log.e("jeson", inputFile.getAbsolutePath());

        String input = inputFile.getAbsolutePath();

        //Surface传入到Native函数中，用于绘制
        Surface surface = videoView.getHolder().getSurface();
//        player.render();
        //player.render(input, surface);

        //String input = new File(Environment.getExternalStorageDirectory(),"hehuoren.flv").getAbsolutePath();
        //String output = new File(Environment.getExternalStorageDirectory(),"Justin Bieber - Boyfriend.pcm").getAbsolutePath();
        //player.sound(input, output);
//        VideoUtils.decode(input,new File(Environment.getExternalStorageDirectory(),"Justin.yuv").getAbsolutePath());

        player.play(input, surface);
//        android/media/AudioTrack

    }

    public void startView(View view) {
    }
}
